package Thread;

/**
 * @projectName: Thread-20250806
 * @package: Thread
 * @className: Homework4
 * @author: Tongxinxin
 * @description: 有三个线程，线程名称分别为：a，b，c。
 * 每个线程打印自己的名称。
 * 需要让他们同时启动，并按 c，b，a的顺序打印
 * @date: 2025/8/9 20:57
 * @version: 1.0
 */
public class Homework4 {
    public static void main(String[] args) throws InterruptedException {
        Object locker=new Object();
        Thread a=new Thread(()->{
            synchronized (locker) {
                System.out.println("a");
            }
        });
        Thread b=new Thread(()->{
            synchronized (locker) {
                System.out.println("b");
            }
        });
        Thread c=new Thread(()->{
            synchronized (locker) {
                System.out.println("c");
            }
        });
        c.start();
        c.join();
        b.start();
        b.join();
        a.start();
        a.join();
        System.out.print("\n");
    }
}
